#ifndef PEARALGORITHM_H
#define PEARALGORITHM_H


#ifndef __APPLE__
#  include "halconcpp/HalconCpp.h"
#  include "halconcpp/HDevThread.h"
#  if defined(__linux__) && !defined(NO_EXPORT_APP_MAIN)
#    include <X11/Xlib.h>
#  endif
#else
#  ifndef HC_LARGE_IMAGES
#    include <HALCONCpp/HalconCpp.h>
#    include <HALCONCpp/HDevThread.h>
#  else
#    include <HALCONCppxl/HalconCpp.h>
#    include <HALCONCppxl/HDevThread.h>
#  endif
#  include <stdio.h>
#  include <HALCON/HpThread.h>
#  include <CoreFoundation/CFRunLoop.h>
#endif

using namespace HalconCpp;


class AlgorithmParameters
{
public:
    static AlgorithmParameters* getInstance()
    {
        static AlgorithmParameters param;
        return &param;
    }

    HObject srcImage;
    HObject resultImage;
    HTuple minArea;
    HTuple minNumber;
    HTuple minRatio;
    HTuple maskSize;
    HTuple minDameter;
    HTuple pixelSize;
    HTuple result;

private:
    AlgorithmParameters()=default;
};

// Procedure declarations
// Chapter: File
// Short Description: Parse a filename into directory, base filename, and extension
void parse_filename (HTuple hv_FileName, HTuple *hv_BaseName, HTuple *hv_Extension,
                    HTuple *hv_Directory);
// Chapter: Graphics / Text
// Short Description: This procedure writes a text message.
void disp_message (HTuple hv_WindowHandle, HTuple hv_String, HTuple hv_CoordSystem,
                  HTuple hv_Row, HTuple hv_Column, HTuple hv_Color, HTuple hv_Box);
// Local procedures
void preprocess (HObject ho_Image, HObject *ho_ResImage, HTuple hv_Alpha);
void LEP_HDR (HObject ho_Image, HObject *ho_ResImage, HTuple hv_LogGain, HTuple hv_Alpha,
             HTuple hv_Beta, HTuple hv_WinSize, HTuple hv_Intensity, HTuple hv_GaussSizes,
             HTuple hv_GaussOnOff, HTuple hv_MaxPercentile, HTuple hv_MinPercentile);
void calculatePercentile (HTuple hv_Datas, HTuple hv_percentile, HTuple *hv_Res);
void enhance_details (HObject ho_Image, HObject *ho_ResImage, HTuple hv_m);
void LEP_filter (HObject ho_SrcImage, HObject *ho_ResImage, HTuple hv_A, HTuple hv_B,
                HTuple hv_WinSize);
void sobelEdgeCheck (HObject ho_SrcImage, HObject ho_LEPImage, HObject *ho_ResRegions,
                    HTuple hv_MinSize);
void laplaceEdgeCheck (HObject ho_SrcImage, HObject ho_LEPImage, HObject *ho_ResRegions,
                      HTuple hv_MinSize);
void checkSolder (HObject ho_SrcImage, HObject ho_LEPImage, HObject *ho_Region, HTuple hv_MinRB,
                 HTuple hv_MaskSize, HTuple *hv_Result);
void checkDotShadow (HObject ho_SrcImage, HObject ho_LEPImage, HObject ho_LEPImageShadow,
                    HObject *ho_Region, HTuple hv_MinArea, HTuple hv_MinNumber, HTuple hv_MinRatio,
                    HTuple hv_MaskSize, HTuple hv_MinDiameter, HTuple *hv_Result);
void Check (HObject ho_SrcImage, HObject *ho_ResImage, HTuple hv_MinArea, HTuple hv_MinNumber,
           HTuple hv_MinRatio, HTuple hv_MaskSize, HTuple hv_MinDiameter, HTuple hv_PixelSize,
           HTuple *hv_Result);

#endif // PEARALGORITHM_H
